package com.example;

import androidx.appcompat.app.AppCompatActivity;

import android.app.DatePickerDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.DatePicker;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.zytphone.R;

import java.text.BreakIterator;
import java.util.Calendar;

public class DailyrePortActivity extends AppCompatActivity {
    private ImageView image;
    private TextView text;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dailyre_port);
        initview();
        image.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showDatePickDlg();
            }
        });

    }

    //日历
    private void showDatePickDlg() {
        Calendar calendar= Calendar.getInstance();
        DatePickerDialog dialog=new DatePickerDialog(DailyrePortActivity.this, new DatePickerDialog.OnDateSetListener() {
            @Override
            public void onDateSet(DatePicker datePicker, int year, int monthOfYear, int dayOfMonth) {
                DailyrePortActivity.this.text.setText(year+ "/" + monthOfYear + "/" + dayOfMonth);
            }
        }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH)+1, calendar.get(Calendar.DAY_OF_MONTH));
        dialog.show();
    }


    //初始化
    private void initview() {
        image=findViewById(R.id.image);
        text=findViewById(R.id.text);
    }
}